import BasePageCtrl, { AnimType } from "./BasePageCtrl";
import n from "./AudioManager"
import l from "./AbTestMgr"
import s from "./PeripheralSystemDataMgr"
import c from "./frameworkManager"
import u from "./EngineUtil"
import p from "./MatchGameData"
import d from "./BasePageCtrl"
import h from "./PageMgr"
import f from "./UiManage"
import UiManager from "./UiManage";
import ArriveCityPage from "./ArriveCityPage";

const { ccclass, property } = cc._decorator;

@ccclass
export default class ArriveCityPageCtrl extends BasePageCtrl {

    @property(cc.Node)
    ui: cc.Node = null;

    @property(cc.Node)
    cityBgPos: cc.Node = null;

    @property(cc.Node)
    topPos: cc.Node = null;


    public v = ["成 都", "重 庆", "贵 州", "云 南", "桂 林", "三 亚", "澳 门", "广 州", "香 港", "中国·台湾", "厦 门", "杭 州", "上 海", "南 京", "黄 山", "南 昌", "长 沙", "武 汉", "洛 阳", "西 安", "泰 山", "天 津", "秦皇岛", "沈 阳", "长 春", "哈尔滨", "呼和浩特", "西 宁", "敦 煌", "新 疆", "西 藏", "北 京"];
    public b = ["成 都", "千厮门长江大桥", "黄果树瀑布", "玉龙雪山", "十里画廊", "亚龙湾", "大三巴牌坊", "广州塔", "庙街夜市", "台北101", "双子塔", "西湖", "东方明珠塔", "南京长江大桥", "山顶迎客松", "滕王阁", "岳麓山爱晚亭", "武汉大学", "白马寺", "大雁塔", "“五岳独尊”石刻", "天津之眼", "阿那亚", "故宫", "南湖公园", "冰雪大世界", "呼和塔拉草原", "塔尔寺", "莫高窟", "喀纳斯湖", "布达拉宫", "北京"]

        onLoad() {
            var t = this;
            this.onUILoad();
            this._animType = AnimType.SCALE;
            this._touchControl = false;
            this._hasPeneLock = true;
            this._hasBlack = true;
            this._hasTouchLock = false;
            this._hasBlackTouch = false;
            this._showWinSize = true;
            this._reuse = false;
            super.onLoad();
            this.addButtonListen();
            this.scheduleOnce(function () {
                t.playShowCityAction();
            }, .5);
        };
        start() { };
        onUILoad() {
            this.ui = this.node.addComponent(ArriveCityPage);
        };
        addButtonListen() {
           UiManager.addButtonListen(this.ui.btn_continue, this.clickContinue, this);
        };
        clickContinue() {
            this.clickClose();
            h.showPage("ArriveCityRewardPage");
        };
        setCurLoactionBg(e) {
            var t = this, a = s.getCurryCityBg();
            if (a) this.ui.newCityBg.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(a); else {
                if (null == e) {
                   UiManager.loadSpriteFrame(this.ui.newCityBg, "cityBg", "bg_1");
                    return;
                }
                var o = "https://static.dayclover.com/wx_game/feie/bg_" + e + ".png";
                u.loadRemoteImg(o).then( (e) => {
                    c.log("到达新城市===当前没有获取到现在加载====成功");
                    t.ui.newCityBg.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(e);
                }).catch(function () {
                    UiManager.loadSpriteFrame(t.ui.newCityBg, "cityBg", "bg_1");
                    c.log("到达新城市===当前没有获取到现在加载====失败用默认的了");
                });
            }
        };
        playShowCityAction() {
            var e = this, t = s.getTravelLocation(), a = s.getTravleData().time, o = t.location;
            n.getInstance().playMusic("picout");
            cc.tween(this.ui.cityBg).by(1, {
                x: 0,
                y: -800
            }).call(function () {
                cc.tween(e.ui.topNode).by(.25, {
                    x: 0,
                    y: 180
                }).call(function () {
                    e.setCurLoactionBg(o);
                    e.ui.newCityTipsNode.active = false;
                    e.ui.topNode.active = false;
                    e.ui.des.active = false;
                    e.ui.arriveDateLabel.getComponent(cc.Label).string = a;
                    e.ui.placeNamelabel.getComponent(cc.Label).string = b[o - 1];
                    cc.tween(e.ui.upBg).to(1, {
                        x: e.ui.upBg.x,
                        y: e.ui.upBg.y,
                        opacity: 0
                    }).call(function () {
                        e.ui.arriveDateLabel.active = true;
                        e.ui.placeNamelabel.active = true;
                        var t = l.isDmthFlag();
                        p.isOppoChannel() || t || l.getDmth2Ab1() || l.getDmth2Ab2() ? e.ui.cityNameBg.active = false : e.ui.cityNameBg.active = true;
                        e.ui.btn_continue.active = true;
                        var a = v[o - 1];
                        e.ui.cityName.getComponent(cc.Label).string = a;
                    }).start();
                }).start();
            }).start();
        };
        clickClose() {
            this.hide();
        };
        static prefabUrl = "ArriveCityPage";
        static className = "ArriveCityPageCtrl";
        // return r([m, _("UI/pages/ArriveCityPageCtrl")], t);
    }